package com.qf.air.service.impl;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qf.air.service.ChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author ASUS
 * @version V1.0
 * @Project air
 * @Package com.qf.air.service.impl
 * @Date 2021/11/5 21:24
 */
@Service
public class ChartServiceImpl implements ChartService {

    @Autowired
    private ObjectMapper objectMapper;

    @Autowired
    private RestTemplate restTemplate;

    @Override
    public List<Map> districtCount() throws IOException {
        String resultString = restTemplate.getForObject("http://localhost:8079/air/districtCount", String.class);
        List<Map> result = objectMapper.readValue(resultString, new TypeReference<List<Map>>() {
        });
        return result;
    }
}
